package com.revel.cloud.nacos.example.controller.trade;

import com.revel.cloud.nacos.example.entity.trade.Order;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : revel
 * @Date: 2022/6/1 18:02
 * @Description:
 */
@RestController
@RequestMapping("/order")
public class TradeController {
    @RequestMapping("/helloNacos")
    public String helloNacos(){
        return "你好，nacos！";
    }

    @RequestMapping("/findOrderList")
    public List<Order> findOrderList(){
        List<Order> list = new ArrayList<Order>();
        for(int i=0;i< 5;i++){
            Order order = new Order();
            order.setOrderNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmSss")));
            order.setDetailed("这是第"+i+"个订单");
            order.setPrice(new BigDecimal(i));
            list.add(order);
        }
        return list;
    }
}
